package com.woniu.liuzhougov.itemAndTask.service.impl;

import com.woniu.liuzhougov.itemAndTask.dao.AreaMapper;
import com.woniu.liuzhougov.itemAndTask.pojo.Area;
import com.woniu.liuzhougov.itemAndTask.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Transactional(rollbackFor = Exception.class)
@Service
public class AreaServiceImpl implements AreaService {

    @Resource
    private AreaMapper areaMapper;


    /**
     * 查询所有 地区 分类
     * @return
     */
    @Override
    public List<Area> searchAllTypeOfArea() {
        return areaMapper.searchAllTypeOfArea();
    }

    @Override
    public List<Area> selAll() {
        return areaMapper.selAll();
    }

    @Override
    public String insert(Area area) {
        try {
            areaMapper.insertSelective(area);
        }catch (Exception e){
            return "false";
        }
        return "success";
    }

    @Override
    public String update(Area area) {
        try {
            areaMapper.updateByPrimaryKey(area);
        }catch (Exception e){
            return "false";
        }
        return "success";
    }

    @Override
    public String delete(int areaId) {

        try {
            areaMapper.deleteByPrimaryKey(areaId);
        }catch (Exception e){
            return "false";
        }
        return "success";
    }
}
